--object class providing extensible instantiation mechanism via
--overridable __init() and __meta fields.
setfenv(1, require'winapi.oo')

Object = class()

function Object:__subclass(c) --class constructor
	c.__call = self and self.__call --static inheritance of parent metamethod
	c.__meta = {__index = c} --dynamic inheritance of class fields
end

function Object:__init(...) end --object constructor

function Object:__call(...) --don't override this, override __init instead.
	local o = setmetatable({}, self.__meta)
	o:__init(...)
	return o
end


if not ... then
local c = class(Object)
function c:__init(...) print('init:', ...) end --dummy constructor
local o = c('hi', 'there')
assert(o.__index == Object) --parent class
assert(o.unknown == nil) --non-existent property
end

